<script>
function isMobile() {
    return (/phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone|webOS|android/i.test(navigator.userAgent))
}
var _isMobile=isMobile();
_h=h= Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
var sWidth = parseInt((window.innerWidth > 0) ? window.innerWidth : screen.width);
if(sWidth>750){sWidth=750;}
console.log(_isMobile);
//if(sWidth>540){sWidth=540;}
var _rate=(sWidth/750);
if(h<_rate*1206){
  h=_rate*1206;
}
function setKe(cname, cvalue){
  var cname='ak4'+cname;
    var d = new Date();
    d.setTime(d.getTime() + (1000*60*60*24*2)); //15分钟
    var expires = "expires="+ d.toUTCString();
    document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
function getke(cname) {
  var cname='ak4'+cname;
    var name = cname + "=";
    var decodedCookie = decodeURIComponent(document.cookie);
    var ca = decodedCookie.split(';');
    for(var i = 0; i <ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') {
            c = c.substring(1);
         }
         if (c.indexOf(name) == 0) {
            return c.substring(name.length, c.length);
         }
     }
    return "";
}
function chinanum(num){
    var china = new Array('零','一','二','三','四','五','六','七','八','九');  
    var arr = new Array();
    var num=num+'';
    var english = num.split("")  
    for(var i=0;i<english.length;i++){
        arr[i] = china[english[i]];
    }
    if(2 == english.length){
        if('一' == arr[0]){
          if ('零' == arr[1]) {
              return '十';
          }
          return ('十'+arr[1]);
        }else{
          if ('零' == arr[1]) {
               return (arr[0]+'十');
          }
          return (arr[0]+'十'+arr[1]);
        }
    }else{
      return arr.join("")  
    }
}
Array.prototype.shuffle = function(){
    let array = this;
    let len = array.length;
    for (let i = len - 1; i > 0; i--) {
      let j = Math.floor(Math.random() * (i + 1));
      [array[i], array[j]] = [array[j], array[i]];
    }
}
var _uid='<?php echo $uid; ?>';
var _uPhone='';
var _userDan={};
var _userDuo={};
var _userTian={};
var _curId=0;
var _uNianji=6;
//_curId=78; //tests
var _yanz='<?php echo $yanz ?>';
var _theMin=20; //倒计时时间 
_leftTime=0;
$(function(){
  $(".p1").show(); 
 
  $('.container, .page').width(sWidth).height(h);
  $('.p-b').height(_rate*1206);
  $('.p1-t1').css({"top":_rate*72});
  $('.p1-bmin').width(_rate*490).height(_rate*164).css({"top":_rate*610, "left":_rate*123});
  $('#zhu-name').width(_rate*368).height(_rate*76).css({"top":_rate*295, "left":_rate*278});
  $('#zhu-nianji').width(_rate*368).height(_rate*76).css({"top":_rate*420, "left":_rate*278});
  $('#zhu-phone').width(_rate*368).height(_rate*76).css({"top":_rate*547, "left":_rate*278}); 
  
  $('#shtian-code').width(_rate*180).height(_rate*68).css({"top":_rate*665, "left":_rate*278});
  $('.shtian-ok, .nantian-ok').width(_rate*476).height(_rate*100).css({"top":_rate*965, "left":_rate*138});
  $('.shtian-y').width(_rate*187).css({"top":_rate*659, "left":_rate*470});
  $('.shtian-miao').width(_rate*187).height(_rate*81).css({"top":_rate*659, "left":_rate*470,"line-height":_rate*81+'px'});

   
  $('.zhu-ok').width(_rate*480).height(_rate*130).css({"top":_rate*950, "left":_rate*142});
  $('.dan-b1').height(_rate*25).css({"top":_rate*88, "left":_rate*72});
  $('.dan-b1-y').width(_rate*586);
  $('.dan-b1-x').width(0);
  
  $('.dan-title, .tian-title, .duo-title').css({"top":_rate*134});
  $('.tian-notice').css({"top":_rate*230});

  $('.up-btn').width(_rate*290).css({"left":_rate*80});
  $('.next-btn').width(_rate*290).css({"left":_rate*382});
  $('.dan-up, .dan-next, .duo-up, .duo-next').css({"top":_rate*1030});
  $('.tian-up, .tian-next').css({"top":_rate*630});

  $('.yib-abcd, .duo-abcd').css({"top":_rate*480});
  $('.yib-li, .duo-li').height(_rate*100).css({"line-height":_rate*55+'px','margin-bottom':_rate*6});
  $('.yib-li .dx-li-ico').width(_rate*44).height(_rate*44).css({"top":_rate*4, "left":0});
  $('.duo-li .dx-li-ico').width(_rate*47).height(_rate*46).css({"top":_rate*2, "left":0});
  $('.yib-li p, .duo-li p').css({"margin-left":_rate*66});
  $('.time-jiao, .gongxi-ok').width(_rate*440).height(_rate*160).css({"top":_rate*310, "left":_rate*160});
  $('.notice-ok').width(_rate*480).height(_rate*140).css({"top":_rate*940, "left":_rate*140});
  $('.notice-t3').width(_rate*686).height(_rate*630).css({"top":_rate*280});
  $('.notice-t3 img').css({"margin-top":-_rate*60});
  $('.tian input').width(_rate*160);

  $('.dui-t1, .dui-t2, .dui-t3, .dui-t4, .dui-t5').height(_rate*60).css({"left":_rate*276,"line-height":_rate*60+'px'});
  $('.dui-t1').css({"top":_rate*402});
  $('.dui-t2').css({"top":_rate*462});
  $('.dui-t3').css({"top":_rate*526});
  $('.dui-t4').css({"top":_rate*586});
  $('.dui-t5').css({"top":_rate*646});
  $('.dui-ok').width(_rate*476).height(_rate*100).css({"top":_rate*965, "left":_rate*138});

  $('.daoji-t1').width(_rate*442).height(_rate*70).css({"top":_rate*428, "left":_rate*168,'line-height':_rate*70+'px'}); 
  $('.daoji-ok').width(_rate*476).height(_rate*100).css({"top":_rate*965, "left":_rate*138});
  
  $('.tipdan-ok, .tipduo-ok, .tiptian-ok').width(_rate*476).height(_rate*190).css({"top":_rate*740, "left":_rate*138});
   $('.wei-t1, .nostart-t1').css({"top":_rate*200});  
  
  if (sWidth > 748) {
       $('.yib-abcd, .duo-abcd').css({"top":_rate*330});
       $('.dan-up, .dan-next, .duo-up, .duo-next').css({"top":_rate*780});
  }

  if (sWidth < 340) {
     $('.yib-abcd').css({"top":_rate*480});
  }
    
  if(h >= _rate*1333){
        var _cha=h - _rate*1340;
        if(_cha < 0){_cha=0;}
        $('.thebg').css({"top":_cha/2});    
  }

  var _shufCookie80=getke('sz_shufCookie8'); //选择题
  var _shufCookie20=getke('sz_shufCookie2'); // 多选题
  var _shufCookie3=getke('sz_shufCookie3');  //填空题

  
  if('' == _shufCookie80){
      var _shuffle80=[];
      for(var i=1;i<=80;i++){
        _shuffle80.push(i);
      }
      _shuffle80.shuffle();
      setKe('sz_shufCookie8', _shuffle80);
  }else{
     var _shuffle80=_shufCookie80.split(",");
  }

  if('' == _shufCookie20){
      var _shuffle20=[];
      for(var i=1;i<=20;i++){
        _shuffle20.push(i);
      }
      _shuffle20.shuffle();
      setKe('sz_shufCookie2', _shuffle20);
  }else{
     var _shuffle20=_shufCookie20.split(",");
  }

  if('' == _shufCookie3){
      var _shuffle30=[];
      for(var i=1;i<=30;i++){
        _shuffle30.push(i);
      }
      _shuffle30.shuffle();
      setKe('sz_shufCookie3', _shuffle30);
  }else{
     var _shuffle30=_shufCookie3.split(",");
  }
 
 
  var _showId=_shuffle80[_curId];
  $(".dan-title").html("第"+chinanum((_curId+1))+"题（"+(_curId+1)+"/80");
  $(".yib-bt, .yib-abcd").hide();
  $(".yb1-bt"+_showId+", .yb1-t"+_showId).show();

var _userCurStepCookie=getke('sz_userCurStepA'); //当前步骤
var _userIdCookie=getke('sz_userId');
var _userPhoneCookie=getke('sz_phone');
var _userCountEndTime=getke('sz_endTime');
var _userNianJiCookie=getke('sz_userNianJi');
var _userDaNum=getke('sz_userdanum');
var _nianjiZiMu={6:'六年级',7:'七年级',8:'八年级',9:'九年级'};

if (typeof(_userIdCookie) != "undefined" && '' != _userIdCookie && '' != _userDaNum) {
     _uid=_userIdCookie;
}else{
    _userCurStepCookie='';
}
if (typeof(_userNianJiCookie) != "undefined" && '' != _userNianJiCookie) {
     _uNianji=_userNianJiCookie;
}
if(typeof(_shufCookie3) != "undefined" && '' != _shufCookie3 && '' != _userDaNum && '' != _userIdCookie){  //记忆
  
  if('dui' == _userCurStepCookie){
         $(".p1").hide();
         $(".dui").show();
         $.post("./api/?c=getdui", {uid:_uid,nianji:_uNianji,num:_userDaNum}, function(data){
            if('y' == data.s){
                 $(".dui-t1").html(data.n);
                 $(".dui-t2").html(data.p);
                 $(".dui-t3").html(_nianjiZiMu[_uNianji]);
                 $(".dui-t4").html(data.q);
                 $(".dui-t5").html(data.x);
            }
          }, "json");
 
  }
 

  if('dan' == _userCurStepCookie || 'duo' == _userCurStepCookie || 'tian' == _userCurStepCookie){
     var _tmDataStoreCookie=getke('sz_tmData');
     var _tmKeyStoreCookie=getke('sz_tmKey');

     if("" != _tmDataStoreCookie){
        var _tmpTmData=_tmDataStoreCookie.split(",");
        var _tmpTmKey=_tmKeyStoreCookie.split(",");
        for(var _i=0;_i<_tmpTmData.length-1;_i++){
           _userDan[_tmpTmKey[_i]]=_tmpTmData[_i];
           _curId++;
        }
      }
       $(".yib-bt, .yib-abcd").hide();
       $(".dan-title").html("第"+chinanum((_curId+1))+"题（"+(_curId+1)+"/80）");
       var _showId=_shuffle80[_curId];
       $(".yb1-bt"+_showId+", .yb1-t"+_showId).show();
       
       for(var _i=0;_i<_curId;_i++){
          _showId=_shuffle80[_i];
          if(typeof(_userDan[_showId]) != "undefined"){
             $(".yb1-t"+_showId+" .dx-li-ico").attr("src","<?php echo $url; ?>/img/c.png");
             $(".yb1-t"+_showId+" .dx-li-"+_userDan[_showId]).attr("src","<?php echo $url; ?>/img/d.png"); 
          }
        }

     $(".p1").hide();
     $(".dan").show();
     _startCountTime();
     _curId--;

  }
  if('duo' == _userCurStepCookie || 'tian' == _userCurStepCookie){
     _curId=0;
     var _tmDataStoreCookie=getke('sz_tmData2');
     var _tmKeyStoreCookie=getke('sz_tmKey2');

     if("" != _tmDataStoreCookie){
        var _tmpTmData=_tmDataStoreCookie.split(",");
        var _tmpTmKey=_tmKeyStoreCookie.split(",");
        for(var _i=0;_i<_tmpTmData.length-1;_i++){
           _userDuo[_tmpTmKey[_i]]=_tmpTmData[_i];
           _curId++;
        }
      }
      
      for(var _i=0;_i<_curId;_i++){
          _showId=_shuffle20[_i];
          if(typeof(_userDuo[_showId]) != "undefined"){
             console.log(_userDuo[_showId]);
             console.log('......');
             if(_userDuo[_showId].indexOf('a') != -1){
                $(".duo-t"+_showId+" .dx-li-a").attr("src","./img/k2.png");
             }
             if(_userDuo[_showId].indexOf('b') != -1){
                $(".duo-t"+_showId+" .dx-li-b").attr("src","./img/k2.png");
             }
             if(_userDuo[_showId].indexOf('c') != -1){
                $(".duo-t"+_showId+" .dx-li-c").attr("src","./img/k2.png");
             }
             if(_userDuo[_showId].indexOf('d') != -1){
                $(".duo-t"+_showId+" .dx-li-d").attr("src","./img/k2.png");
             }
             

          }
      }

      $(".dan").hide();
      $(".duo-bt, .duo-abcd").hide();
      $(".duo-title").html("第"+chinanum((_curId+1))+"题（"+(_curId+1)+"/20）");
      var _showId=_shuffle20[_curId];
      $(".duo-bt"+_showId+", .duo-t"+_showId).show();
      $(".duo").show();
 

  }
  if('tian' == _userCurStepCookie){
      //初始化单选题
      _curId=0;
        var _tmDataStoreCookie=getke('sz_tmData3');
        var _tmKeyStoreCookie=getke('sz_tmKey3');
        if("" != _tmDataStoreCookie){
          var _tmpTmData=_tmDataStoreCookie.split(",");
          var _tmpTmKey=_tmKeyStoreCookie.split(",");
          for(var _i=0;_i<_tmpTmData.length;_i++){
             _userTian[_tmpTmKey[_i]]={1:decodeURI(_tmpTmData[_i])};
             _curId++;
          }
        }

       _showId=_shuffle30[_curId];


       $(".yib-bt, .yib-abcd").hide();
       $(".tian-title").html("第"+chinanum((_curId+1))+"题（"+(_curId+1)+"/30）");
       $(".tian-bt").hide();
       $(".tian-t"+_showId).show();
       for(var _i=0;_i<_curId;_i++){
        _showId=_shuffle30[_i];
        if (typeof(_userTian[_showId]) != "undefined" && typeof(_userTian[_showId][1]) != "undefined" ) {
             $(".tian-t"+_showId+" .tk-1").val(_userTian[_showId][1]);
        }
      }
  
     $(".p1, .dan, .duo").hide();
     $(".tian").show();
  }


}
  
  var _miaoId=15;
  var _miaoFlag=true;
  function _miaos(){
      $('.shtian-miao').html(_miaoId+'s');
      _miaoId--;
      if(_miaoId < 1){
         _miaoFlag=true;
      }
      if(_miaoId < 0){
        _miaoId=0;
        $('.shtian-miao').html('');
        $(".shtian-y2").show();
        _miaoFlag=true;
        return;
      }
      window.setTimeout(function(){
        _miaos();
      }, 1000);
  }

  $('.shtian-miao').click(function(){
    if(false == _miaoFlag){return;}
    _miaoFlag=false;
    var _phone=$("#zhu-phone").val();
    if('' == _phone){
         _miaoFlag=true;
         _popMsg("请填写初赛预留的手机号码");
           return;  
    }
    console.log(_phone);
    $.post("./api/?c=sms", {uid:_uid,ph:_phone,code:_yanz}, function(data){
            $(".shtian-y2").hide();
            _miaoId=15;
             _miaos();
    }, "json");
  });    
 
  $(".zhu-ok").click(function(){
     var _name=$("#zhu-name").val();
     var _phone=$("#zhu-phone").val();
     var _nianji=$("#zhu-nianji").val();
     var _code=$("#shtian-code").val(); 
     
       

     if('' == _name){
         _popMsg("请填写学生姓名");
           return;  
     }
     if('' == _phone){
         _popMsg("请填写初赛预留的手机号码");
           return;  
     }
     if(_phone.length < 6){
        _popMsg("请填写初赛预留的手机号码");
        return;  
     }
     if('' == _nianji){
         _popMsg("请选择年级");
         return; 
     }

     _uPhone=_phone;
    $.post("./api/?c=setu", {uid:_uid,n:_name,ph:_phone,nianji:_nianji,code:_code,code2:_yanz}, function(data){
          if('y' == data.s){
             $(".zhu").hide();
             $(".dui").show();
             $(".dui-t1").html(data.n);
             $(".dui-t2").html(_phone);
             $(".dui-t3").html(_nianjiZiMu[_nianji]);
             $(".dui-t4").html(data.q);
             $(".dui-t5").html(data.x);
             
             setKe('sz_userId', _uid);
             setKe('sz_userCurStepA', 'dui');
             setKe('sz_userNianJi', _nianji);
             setKe('sz_userdanum', data.zd);
             _userDaNum=data.zd;
             _uNianji=_nianji;
             
               
          }else{
            if(data.e == 'code'){
             _popMsg("验证码不正确");
            return; 
            }else{
            $(".wei").show();
            return; 
            }
            
          }
    }, "json");

  });
  
  $(".p1-bmin").click(function(){
    var _phone='';
 console.log(_userPhoneCookie);
    if(typeof(_userPhoneCookie) != "undefined" && '' != _userPhoneCookie){  //记忆
        _phone=_userPhoneCookie;
    }
    console.log('k'+_userCurStepCookie);
    if(typeof(_userCurStepCookie) != "undefined" && 'end' == _userCurStepCookie){  //记忆
        _popMsg("您已参与过考试");
        return;
    }
 
    $(".p1").hide();
    $(".zhu").show();
    
     
     
  });
  $(".gongxi-ok").click(function(){ 
      window.location.reload();
  });
  
  function _popMsg(msg){
    $(".weui-msg").html(msg);
        $(".js_dialog").show();
  }   
  $(".weui-btn").click(function(){
        $(".js_dialog").hide();
  });

  function _resetABCD(_type, _showId){
      _userDan[_showId]=_type;
      console.log(_userDan);
       var _tmData=[];
       var _tmKey=[];  
       $.each(_userDan,function(key,value) {
            _tmKey.push(key);
            _tmData.push(value);
        }); 
        setKe('sz_tmData', _tmData);
        setKe('sz_tmKey', _tmKey);
        setKe('sz_userCurStepA', 'dan');
      
      $(".yb1-t"+_showId+" .dx-li-ico").attr("src","<?php echo $url; ?>/img/c.png");
      $(".yb1-t"+_showId+" .dx-li-"+_type).attr("src","<?php echo $url; ?>/img/d.png");
 }

 function _duoABCD(_type, _showId){
      
    if('a' == _type){
      if(1 == _duoxABCD['a']){
         _duoxABCD['a']='';

         $(".duo-t"+_showId+" .dx-li-"+_type).attr("src","./img/k.png");
      }else{
         _duoxABCD['a']=1;

         $(".duo-t"+_showId+" .dx-li-"+_type).attr("src","./img/k2.png");
      }
    }

    if('b' == _type){
      if(1 == _duoxABCD['b']){
         _duoxABCD['b']='';
         $(".duo-t"+_showId+" .dx-li-"+_type).attr("src","./img/k.png");
      }else{
         _duoxABCD['b']=1;
         $(".duo-t"+_showId+" .dx-li-"+_type).attr("src","./img/k2.png");
      }
    }

    if('c' == _type){
      if(1 == _duoxABCD['c']){
         _duoxABCD['c']='';
         $(".duo-t"+_showId+" .dx-li-"+_type).attr("src","./img/k.png");
      }else{
         _duoxABCD['c']=1;
         $(".duo-t"+_showId+" .dx-li-"+_type).attr("src","./img/k2.png");
      }
    }

    if('d' == _type){
      if(1 == _duoxABCD['d']){
         _duoxABCD['d']='';
         $(".duo-t"+_showId+" .dx-li-"+_type).attr("src","./img/k.png");
      }else{
         _duoxABCD['d']=1;
         $(".duo-t"+_showId+" .dx-li-"+_type).attr("src","./img/k2.png");
      }
    }  
      
 }

   $(".yib-abcd .dx-a").click(function(){
       _showId=_shuffle80[_curId];
       console.log(_showId);
       _resetABCD('a', _showId);
        
   });
   $(".yib-abcd .dx-b").click(function(){
       _showId=_shuffle80[_curId];
       _resetABCD('b', _showId);
   });
   $(".yib-abcd .dx-c").click(function(){
       _showId=_shuffle80[_curId];
       _resetABCD('c', _showId);
        
   });
   $(".yib-abcd .dx-d").click(function(){
      _showId=_shuffle80[_curId];
      _resetABCD('d', _showId);
   });
   function _getABCD(){
        var _data='';
        if(1 == _duoxABCD.a){
          _data+='a';
        }
        if(1 == _duoxABCD.b){
          _data+='b';
        }
        if(1 == _duoxABCD.c){
          _data+='c';
        }
        if(1 == _duoxABCD.d){
          _data+='d';
        }
        return _data;
  }
   var _duoxABCD={a:'',b:'',c:'',d:''};
   $(".duo-abcd .dx-a").click(function(){
       _showId=_shuffle20[_curId];
       _duoABCD('a', _showId); 
   });
   $(".duo-abcd .dx-b").click(function(){
       _showId=_shuffle20[_curId];
       _duoABCD('b', _showId); 
   });
   $(".duo-abcd .dx-c").click(function(){
       _showId=_shuffle20[_curId];
       _duoABCD('c', _showId); 
   });
   $(".duo-abcd .dx-d").click(function(){
       _showId=_shuffle20[_curId];
       _duoABCD('d', _showId); 
   });

  $('.dan-next').click(function(){
        _curId++;
        if(_curId > 79){
          $.post("./api/?c=setdan", {yi:_userDan,op:_uid,nianji:_uNianji,ud:_userDaNum,leftTime:_leftTime}, function(data){
          }, "json");
 
          _curId=0; //填空初始化
          _showId=_shuffle20[_curId];
          $(".duo-bt"+_showId+", .duo-t"+_showId).show();
          $(".duo-title").html("第"+chinanum((_curId+1))+"题（"+(_curId+1)+"/20）");
          $(".dan").hide();
          $(".tipduo").show();
           
           console.log('提交+end'); 
           return;
        }
        
        $(".yib-bt, .yib-abcd").hide();
        $(".dan-title").html("第"+chinanum((_curId+1))+"题（"+(_curId+1)+"/80）");
        var _showId=_shuffle80[_curId];
        $(".yb1-bt"+_showId+", .yb1-t"+_showId).show();
              
        $(".next-btn-h").attr("src","<?php echo $url; ?>/img/r-btn.png");
        window.setTimeout(function(){
          $(".next-btn-h").attr("src","<?php echo $url; ?>/img/h-btn.png");
        }, 200);
        setKe('sz_userCurStepA', 'dan');
         
   });

  $('.dan-up').click(function(){
      if(0 == _curId){return;}
      if(_curId < 0){return;}
       _curId--;
       $(".dan-title").html("第"+chinanum((_curId+1))+"题（"+(_curId+1)+"/80）");
       var _showId=_shuffle80[_curId];
       console.log(_showId);

       $(".yib-bt, .yib-abcd").hide();
       $(".yb1-bt"+_showId+", .yb1-t"+_showId).show();
       
        
       $(".up-btn-h").attr("src","<?php echo $url; ?>/img/r-btn.png");
       window.setTimeout(function(){
          $(".up-btn-h").attr("src","<?php echo $url; ?>/img/h-btn.png");
           
        }, 200);
       setKe('sz_userCurStepA', 'dan');
  
   });


  $('.duo-next').click(function(){
        _curId++;

        var _tmpabcd=_getABCD();
        if('' != _tmpabcd){
         _userDuo[_shuffle20[_curId-1]]=_getABCD();
         var _tmData=[];
         var _tmKey=[];  
         $.each(_userDuo,function(key,value) {
              _tmKey.push(key);
              _tmData.push(value);
          }); 
          setKe('sz_tmData2', _tmData);
          setKe('sz_tmKey2', _tmKey);
        }

        if(_curId > 19){
          $.post("./api/?c=setduo", {duo:_userDuo,op:_uid,nianji:_uNianji,ud:_userDaNum,leftTime:_leftTime}, function(data){

          }, "json");

          _curId=0; //填空初始化
          _showId=_shuffle30[_curId];

          $(".tian-t"+_showId).show();
          $(".tian-title").html("第"+chinanum((_curId+1))+"题（"+(_curId+1)+"/30）");
          $(".dan").hide();
          $(".tiptian").show();
  
           console.log('提交+end'); 
           return;
        }
 
        
         
        _duoxABCD={a:'',b:'',c:'',d:''};
        
        console.log(_userDuo);
        $(".duo-bt, .duo-abcd").hide();
        $(".duo-title").html("第"+chinanum((_curId+1))+"题（"+(_curId+1)+"/20）");
        var _showId=_shuffle20[_curId];
        $(".duo-bt"+_showId+", .duo-t"+_showId).show();
              
        $(".next-btn-h").attr("src","<?php echo $url; ?>/img/r-btn.png");
        window.setTimeout(function(){
          $(".next-btn-h").attr("src","<?php echo $url; ?>/img/h-btn.png");
        }, 200);
        setKe('sz_userCurStepA', 'duo');
         
   });

  $('.duo-up').click(function(){
      if(0 == _curId){
        
      _curId=79;
      $(".duo").hide();
      $(".dan").show();
       $(".duo-title").html("第"+chinanum((_curId+1))+"题（"+(_curId+1)+"/80）");
       var _showId=_shuffle80[_curId];
       $(".yib-bt, .yib-abcd").hide();
       $(".yb1-bt"+_showId+", .yb1-t"+_showId).show();
       $(".up-btn-h").attr("src","<?php echo $url; ?>/img/r-btn.png");
       window.setTimeout(function(){
          $(".up-btn-h").attr("src","<?php echo $url; ?>/img/h-btn.png");
        }, 200);
      
        return;
      }
      if(_curId < 0){return;}
       _curId--;
       $(".duo-title").html("第"+chinanum((_curId+1))+"题（"+(_curId+1)+"/20）");
       var _showId=_shuffle20[_curId];

       $(".duo-bt, .duo-abcd").hide();
       $(".duo-bt"+_showId+", .duo-t"+_showId).show();

       
       if(_userDuo[_showId].indexOf('a') != -1){
           _duoxABCD['a']=1;
       }
       if(_userDuo[_showId].indexOf('b') != -1){
           _duoxABCD['b']=1;
       }
       if(_userDuo[_showId].indexOf('c') != -1){
           _duoxABCD['c']=1;
       }
       if(_userDuo[_showId].indexOf('d') != -1){
           _duoxABCD['d']=1;
       }
        
       $(".up-btn-h").attr("src","<?php echo $url; ?>/img/r-btn.png");
       window.setTimeout(function(){
          $(".up-btn-h").attr("src","<?php echo $url; ?>/img/h-btn.png");
           
        }, 200);
       setKe('sz_userCurStepA', 'duo');
  
   });


  
    
    $('.tian-next').click(function(){
        _curId++;
        $(".tian-notice").hide();
        var _showId=_shuffle30[_curId-1];
        var _txtA=$(".tian .tian-t"+_showId+' .tk-1').val();
        if ('' != _txtA) {
            _userTian[_showId]={1:_txtA};
           var _tmData=[];
           var _tmKey=[];  
           $.each(_userTian,function(key,value) {
                _tmKey.push(key);
                _tmData.push(encodeURI(value[1]));
            }); 
            setKe('sz_tmData3', _tmData);
            setKe('sz_tmKey3', _tmKey);
        }
        setKe('sz_userCurStepA', 'tian');
        _showId=_shuffle30[_curId];
        
         
        if(_curId > 28){
            $(".next-btn-t").attr("src","<?php echo $url; ?>/img/next-btn2.png");
            $(".next-btn-h").attr("src","<?php echo $url; ?>/img/r-btn.png");  
        }
        if(_curId > 29){
          $.post("./api/?c=settian", {kong:_userTian,op:_uid,nianji:_uNianji,ud:_userDaNum,leftTime:_leftTime}, function(data){
               $(".gongxi").show();
               setKe('sz_userCurStepA', 'end');  
          }, "json");
           console.log('提交+end'); 
           return;
        }
         
        
        $(".yib-bt, .yib-abcd").hide();
        $(".tian-title").html("第"+chinanum((_curId+1))+"题（"+(_curId+1)+"/30）");
        
         $(".tian-bt").hide();
         $(".tian-t"+_showId).show();
              
        $(".next-btn-h").attr("src","<?php echo $url; ?>/img/r-btn.png");
        window.setTimeout(function(){
          $(".next-btn-h").attr("src","<?php echo $url; ?>/img/h-btn.png");
        }, 200);
         
   });

   $('.tian-up').click(function(){
    console.log(_curId);
      if(0 == _curId){ //返回单选
      _curId=19;
      $(".tian").hide();
      $(".duo").show();
       $(".duo-title").html("第"+chinanum((_curId+1))+"题（"+(_curId+1)+"/20）");
       var _showId=_shuffle20[_curId];
       $(".yib-bt, .yib-abcd").hide();
       $(".yb1-bt"+_showId+", .yb1-t"+_showId).show();
       $(".up-btn-h").attr("src","<?php echo $url; ?>/img/r-btn.png");
       window.setTimeout(function(){
          $(".up-btn-h").attr("src","<?php echo $url; ?>/img/h-btn.png");
        }, 200);
       setKe('sz_userCurStepA', 'duo');
        return;
      }
      if(1 == _curId){$(".tian-notice").show();}
      if(_curId < 0){return;}
       _curId--;
       $(".tian-title").html("第"+chinanum((_curId+1))+"题（"+(_curId+1)+"/30）");
       var _showId=_shuffle30[_curId];
        $(".tian-bt").hide();
        $(".tian-t"+_showId).show();
       $(".up-btn-h").attr("src","<?php echo $url; ?>/img/r-btn.png");
       $(".next-btn-t").attr("src","<?php echo $url; ?>/img/next-btn.png");
      $(".next-btn-h").attr("src","<?php echo $url; ?>/img/h-btn.png");  
       window.setTimeout(function(){
          $(".up-btn-h").attr("src","<?php echo $url; ?>/img/h-btn.png");
        }, 200);
      setKe('sz_userCurStepA', 'tian');
  
   });
   
   $('.time-jiao').click(function(){
       $.post("./api/?c=timeend", {yi:_userDan,duo:_userDuo,kong:_userTian,op:_uid,nianji:_uNianji,ud:_userDaNum,leftTime:_leftTime}, function(data){
               $(".gongxi").show();
               setKe('sz_userCurStepA', 'end');  
        }, "json");
        console.log(111);
   });

   $('.notice-ok').click(function(){
       $(".notice").hide();
       $(".dan").show();
       _startCountTime();
   });


  
  var end;
  function _startCountTime(){
    var endDate = new Date();
    var min=endDate.getMinutes();
    endDate.setMinutes(min + _theMin);
    //endDate.setMinutes(min+1); test
    end = endDate.getTime();
    if (typeof(_userCountEndTime) != "undefined" && '' != _userCountEndTime) {
        var date = new Date();  
        var now = date.getTime();
        if ((_userCountEndTime-now) >= 92000){
            end=_userCountEndTime;
        }
    }
    countTime();
    setKe('sz_endTime', end);
  }
  var _zongwidth=_rate*586;
  var _zongTime=60*_theMin *1000; //这里也要修改
  function countTime(){
    var date = new Date();  
    var now = date.getTime();
    _leftTime= end-now; 
    var m,s; 
    if (_leftTime >= 0){
      m = Math.floor(_leftTime/1000/60%60);
      s = Math.floor(_leftTime/1000%60);
      var _tmpS=':'+s;
      if(s<10){
        _tmpS=':0'+s;
      }
      //console.log(_leftTime);
      var _percent=1 - _leftTime/_zongTime + 0.02;
      if(_percent>1){_percent=1;}
      
      $(".dan-b1-x").width(_percent*_zongwidth);
      

      $(".dan-time").html(m + _tmpS );
      setTimeout(countTime,1000); 
    }else{
      $(".dan-time").html("00:00");
      _tmTimeId=0;
      $(".time").show();
      console.log('end');
    }
  }


  var _canDaoji=false;
var intDiff = parseInt(<?php echo ($minute*60 + $second);  ?>);//倒计时总秒数量
function timer(intDiff){
    window.setInterval(function(){

    var day=0,
        hour=0,
        minute=0,
        second=0;//时间默认值
    if(intDiff < 2){
      _canDaoji=true;
      if(intDiff < -1){
        $('.daoji-t1').html("00时 &nbsp; 00分 &nbsp; 00秒");
      return;
      }  
    } 
       
    if(intDiff > 0){
        day = Math.floor(intDiff / (60 * 60 * 24));
        hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
        minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
        second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
    }

    if (minute <= 9) minute = '0' + minute;
    if (second <= 9) second = '0' + second;
    var _hour=hour;
    if (0 == _hour) {
       _hour='00';
    }
    $('.daoji-t1').html(_hour+"时 &nbsp; "+minute+"分 &nbsp; "+second+"秒");
    //$('#hour_show').html('<s id="h"></s>'+hour+'时');
    //$('#minute_show').html('<s></s>'+minute+'分');
    //$('#second_show').html('<s></s>'+second+'秒');
    intDiff--;
    console.log(intDiff);
    }, 1000);
} 



$(".daoji-ok").click(function(){
 
   if(false == _canDaoji){
      _popMsg("考试还未开始");
      return;
   }
  
  

      $(".yib-bt, .yib-abcd").hide();
      $(".dan-title").html("第"+chinanum((_curId+1))+"题（"+(_curId+1)+"/80）");
      var _showId=_shuffle80[_curId];
      console.log(_showId);
      $(".yb1-bt"+_showId+", .yb1-t"+_showId).show();
      
     $(".daoji").hide();
     $(".tipdan").show();
    
});

$(".tipdan-ok").click(function(){
   $(".tipdan").hide();
   $(".dan").show();
   _startCountTime();
    
});
$(".tipduo-ok").click(function(){
   $(".tipduo").hide();
   $(".duo").show();
   
});
$(".tiptian-ok").click(function(){
   $(".tiptian").hide();
   $(".tian").show();
   
});
 

 
$(".wei").click(function(){
     $(".nostart, .wei, .zhu").hide();
     $(".p1").show();
 });
timer(intDiff);
$('.dui-ok').click(function(){
     $.post("./api/?c=checku", {nianji:_uNianji,num:_userDaNum}, function(data){
          if('y' == data.s){
              $(".dui").hide();
              $(".daoji").show();
          }else{
              _popMsg("您已经参加过考试");
              return; 
          }
    }, "json");
     
       
});


  //  
});
</script>